<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Util
 *
 * @author riemerb
 */
class Util {
     public static function isOlderThan($date, $interval) {
         
        $now = new DateTime();
        //date_format($test, 'Y-m-d H:i:s')
        $date_von = new DateTime();
        $date_von = DateTime::createFromFormat('d.m.Y', $date);
        $xAgo = $now->sub(date_interval_create_from_date_string($interval.' days'));
        if ($date_von > $xAgo) {
            return false;
        } else {
            return true;
        }
     }

     public static function isInFuture($date) {
         
        $now = new DateTime();

        $date = DateTime::createFromFormat('d.m.Y', $date);
        if ($date <= $now) {
            return false;
        } else {
            return true;
        }
     }

    public static function randomString($length){  
        $chars = 'b7cd18fg49hjklm3nprstv2w6xz0aei5ou';
        $result = '';
        for ($p = 0; $p < $length; $p++)
        {
            $result .= ($p%2) ? $chars[mt_rand(19, 34)] : $chars[mt_rand(0, 19)];
        }

        return $result;
    }
}

?>
